package com.xusl.spring.transaction;

import com.xusl.spring.conn.JdbcConnection;

import java.sql.SQLException;

/**
 * @Author: xusl
 * @Date: 2021/8/4 10:45 下午
 */
public class TransactionManager {

    private JdbcConnection jdbcConnection;

    public void setJdbcConnection(JdbcConnection jdbcConnection) {
        this.jdbcConnection = jdbcConnection;
    }

    public void startTransaction() throws SQLException {
        jdbcConnection.getConnection().setAutoCommit(false);
    }

    public void commit() throws SQLException {
        jdbcConnection.getConnection().commit();

    }

    public void rollback() throws SQLException {
        jdbcConnection.getConnection().rollback();
    }
}
